import {
	defineStore
} from 'pinia'
import * as API from "../api/api.js"
export const useAppStore = defineStore('useApp', {
	state: () => {
		return {
			titleHeight: 0,
      screenWidth: 0,
			screenHeight: 0,
      safeTop: 0,
      safeBottom: 0
		}
	},
	actions: {
    getTitleHeight() {
      let res = uni.getMenuButtonBoundingClientRect();
      this.titleHeight = res.top;
    },
    getAppSize() {
      return new Promise((resolve, reject) => {
        uni.getSystemInfo({
          success: (res) => {
            console.log(res, 3444444444444)
            this.screenWidth = res.screenWidth;
            this.screenHeight = res.screenHeight;
            this.safeTop = res.safeAreaInsets.top;
            this.safeBottom = res.safeAreaInsets.bottom;
            resolve(res)
          }
        })
      })
    },
    // 手机信息埋点
    onBurialPointTel(params) {
      API.burialPointTel(params).then(res => {
        if (res.code == 0) {
          console.log("手机埋点成功")
        }
      }).catch(err => {
        console.log("手机埋点报错", err)
      })
    }
  }
})

